home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / Gui4Cli / Docs / Tutorials / Clock.rexx < prev    next >
OS/2 REXX Batch file  |  1997-12-02  |  3KB  |  59 lines

  1. /***********************************************************************/
  2. /* This is a small arexx program which gets called from a Gui4Cli      */
  3. /* gui, as follows :                                                   */
  4. /*     > SendRexx AREXX 'Clock.rexx GuiName RoutineName'               */
  5. /* OR  > RUN 'RX Clock.gc GuiName RoutineName'                         */
  6. /* where :                                                             */
  7. /* GuiName     is the name of the calling gui, whose variables will    */
  8. /*             be set and which contains the routine that'll be called */
  9. /* RoutineName is the name of a routine in the above Gui, which will   */
  10. /*             be called every minute.                                 */
  11. /* The variables "time" "date" etc can then be used as needed          */
  12. /***********************************************************************/
  13.  
  14. /* add the rexxsuport.library which provides the Delay() command       */
  15. call addlib('rexxsupport.library',0,-30,0)
  16.  
  17. /* parse the arguments we were sent, into variables "gui" and "routine"*/
  18. parse arg gui routine
  19.  
  20. /* this variable is needed below - see loop after the delay function   */
  21. guifile = "ENV:Gui4Cli/" || gui
  22.  
  23. /* talk to Gui4Cli */
  24. address "Gui4Cli"
  25.  
  26. /* Now we can just issue the Gui4Cli arexx commands directly, as if    */
  27. /* we were in a gui. However, we have to take care of the quotes, so   */
  28. /* that Gui4Cli receives the arguments as it expects them..            */
  29. /* That's what the '"' || things are for.                              */
  30. /* The resulting string will be something like :                       */
  31. /* > SETVAR MYGUI.GC/date "23 Nov 1997"                                */
  32.  
  33. do forever
  34.    setvar   gui || "/time"     '"' || time('c') || '"'
  35.    setvar   gui || "/date"     '"' || date()    || '"'
  36.    setvar   gui || "/day"      '"' || date('w') || '"'
  37.    setvar   gui || "/month"    '"' || date('m') || '"'
  38.    gosub    gui routine
  39.  
  40.    /* Now we have to delay for a minute until we do the loop again..   */
  41.    /* Note that the delay function will return a result - we must put  */
  42.    /* this result somewhere (in this case we store it in "dumy")       */
  43.    /* otherwise arexx would send it to Gui4Cli which wouldn't know     */
  44.    /* what to do with it */
  45.  
  46.    dumy = delay(3000)                          /* delay for one minute */
  47.  
  48.    /* After the delay, we have to check if the gui that called us is   */
  49.    /* still in business. We do this by checking if the gui's file name */
  50.    /* is present in Gui4Cli's env: directory - I'm going to add        */
  51.    /* some way to do this better, but for the moment it suffices..     */
  52.  
  53.    if ~exists(guifile) then
  54.        exit
  55.  
  56. end
  57. exit
  58.  
  59.